<!-- 项目管理 -->
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label mb10">购买记录</p>
        <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
        <dxtable 
        :isshowXz="false" 
        :dataJson="dataJson" 
        :portUrl="portUrl"
         :formJson="formJson" 
         :headBtn="headBtnw"
         v-if="xczxsdfere"
         :qx="qx" ref="databale"></dxtable>

         <n-modal v-model:show="showModal" preset="card" class="Stock-diagnosis">
         <template #header>
         <div>分析记录</div>
         </template>
         <div>
        <fenxiList :iscz="true" @callBack="fdasfdsfrt"></fenxiList>
         </div>
         <template #action>
         <div class="tr">
         <n-button> 取消 </n-button>
         </div>
         </template>
         </n-modal>
    </div>
</template>
<script lang='ts' setup>
import { dxget } from "../../util/index";
import dxtable from "../../components/util/dxtable.vue";
import fenxiList from "./fenxiList.vue";
import { NButton, NImage, NTag } from "naive-ui"
import { h, ref, reactive, render } from "vue";
const databale = ref();
const showModal =ref()
const initeer = () => {
    databale.value.initDataExpose();
};
let dataJson = [
    {
        "title": "标题",
        "type": "input",
        "val": "",
        "icon": "dx-shurukuang",
        "span": 24,
        "key": "title",
        "width": "",
        "search": false,
        "istable": true,
        "required": false,
        render: (row: any) => {
            let jjxzcdsf = JSON.parse(row.title)
            console.log(jjxzcdsf);
            let jsdfds = []
            jjxzcdsf.map(a=>{
                jsdfds.push(h(NTag, {
                    type: "info",
                    class:"ml5 mr5",
                    closable: false,
                    onClose: () => {
                        console.log("关闭");
                    }
                }, {
                    default: () => a.zdui +'vs' +a.kdui
                }))
            })
            return jsdfds
        }
    },
    {
        "title": "中奖截图",
        "type": "imglist",
        "val": [],
        "icon": "dx-ai-img-list",
        "span": 24,
        "key": "jietu",
        "width": "",
        "search": false,
        "istable": true,
        "required": false
    },
    {
        "title": "是否命中",
        "type": "radio",
        "icon": "dx-radiobox",
        "val": "",
        "opt": [
            {
                "label": "中",
                "value": 1
            },
            {
                "label": "未中",
                "value": 2
            }
        ],
        "span": 12,
        "key": "ismz",
        "width": "",
        "search": false,
        "istable": true,
        "required": false,
        render: (row: any) => {
            return row.ismz == 1 ? h(NTag, {
                type: "success",
                closable: false,
                onClose: () => {
                    console.log("关闭");
                }
            }, {
                default: () => "命中"
            }) : h(NTag, {
                type: "error",
                closable: false,
            },{
                default: () => "未命中"
            })
        }
    },

    {
        title: "添加时间",
        key: "addTime",
        width: 150,
    }];
const xczxsdfere = ref(true)


const qx = {
    DeletePermissionID: "zqgmjldel", //删除
    EditPermissionIdentifier: "zqgmjlbj", // 编辑
    NewPermissionIdentifier: "zqgmjlxz", // 新建
    ViewPermissionID: "zqgmjlck", // 查看
};
const portUrl = "dxgj/dxgmjl/dxgmjl";

let formJson = ref([
    {
        "title": "标题",
        "val": "1",
        "key": "title",
    },
    {
        "title": "方案内容",
        "val": "2",
        "key": "fxbg",
    },
    {
        "title": "中奖截图",
        "type": "imglist",
        "val": [],
        "icon": "dx-ai-img-list",
        "span": 24,
        "key": "jietu",
        "width": "",
        "search": false,
        "istable": true,
        "required": false
    },
    {
        "title": "是否命中",
        "type": "radio",
        "icon": "dx-radiobox",
        "val": "",
        "opt": [
            {
                "label": "中",
                "value": '1'
            },
            {
                "label": "未中",
                "value": '2'
            }
        ],
        "span": 12,
        "key": "ismz",
        "width": "",
        "search": false,
        "istable": true,
        "required": false
    }
])

const fdasfdsfrt = async(ids)=>{
    xczxsdfere.value = false
    const {data}:any = await dxget('dxgj/api/kxzxcdsfdf',{ids})
    formJson.value[0].val = data.title
    formJson.value[1].val = data.fxbg
    console.log(formJson);
    xczxsdfere.value = true
 setTimeout(() => {
    showModal.value = false
    databale.value.xinhasr()
 }, 500);
  
}
const headBtnw = ref([
    {
        name: "新增",
        jy: true,
        type: "info",
        clickFun: () => {
           
            showModal.value = true
        },
    },
]);
</script>
<style scoped></style>